package com.huawei;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Description: HJ90 合法IP
 * <p>
 * 1、每段长度等于0，或者长度大于4，都不合法
 * 2、每段的字符必须是数字
 * 3、除0以外，所有0开头的字符串都是非法的
 * 4、每段对应的数大于255，也是非法的
 *
 * @author weiruibai.vendor
 * Date: 2022/8/24 09:54
 */
public class HJ90 {

    /**
     * case
     * 1、01.2.3.8
     * 2、+1.2.3.8
     *
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        System.out.println(Integer.toBinaryString(255));

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] strs = str.split("\\.");
        if (strs.length != 4) {
            System.out.println("NO");
            return;
        }
        boolean isValid = true;
        for (int i = 0; i < 4; i++) {
            try {
                String s = strs[i];
                if (s == null || s.length() == 0) {
                    isValid = false;
                    break;
                }
                if ((s.length() > 1 && s.charAt(0) == '0') || !Character.isDigit(s.charAt(0))) {
                    isValid = false;
                    break;
                }
                int num = Integer.parseInt(s);
                if (num > 256) {
                    isValid = false;
                    break;
                }

            } catch (Exception e) {
                isValid = false;
            }

        }
        System.out.println(isValid ? "YES" : "NO");
    }
}
